
//
//  Singleton.m
//  11-一次性执行
//
//  Created by wanglei on 16/12/19.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "Singleton.h"

@implementation Singleton

+ (instancetype)shareInstance{
    static Singleton* single;
    static dispatch_once_t onceToken;
    NSLog(@"执行block之前的onceToken的值为%ld",onceToken);
    //①onceToken = 0;
    
    dispatch_once(&onceToken, ^{
        
        NSLog(@"执行block之中的onceToken的值为%ld",onceToken);
        //②onceToken = 140734731430192
        single = [[Singleton alloc] init];
    });
    
    NSLog(@"执行block之后的onceToken的值为%ld",onceToken);
    //③onceToken = -1;
    return single;
}


@end
